package org.springonrails.appgen;

import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;

import org.springonrails.RailsException;

public class TemplatePluginClassLoader extends URLClassLoader 
{

	protected TemplatePluginClassLoader(URL[] urls) 
	{
		super(urls);		
	}
	
	public static TemplatePluginClassLoader createInstance(URL url)
	{
		return new TemplatePluginClassLoader(new URL[]{url});
	}
	
	public static TemplatePluginClassLoader createInstance(URI uri)
	{
		TemplatePluginClassLoader loader = null;
		try{
			loader =  new TemplatePluginClassLoader(new URL[]{uri.toURL()});
		}catch(Exception err){
			throw new RailsException("Invalid plugin URI.", err);
		}
		return loader;
	}
	
}
